package com.xiaodu.acer.phoneplay.presenter;

import com.xiaodu.acer.phoneplay.bean.AppInfo;
import com.xiaodu.acer.phoneplay.common.rx.RxHttpReponseCompat;
import com.xiaodu.acer.phoneplay.data.AppInfoModel;
import com.xiaodu.acer.phoneplay.presenter.contract.AppDetailContract;
import com.xiaodu.acer.phoneplay.ui.base.BasePresenter;

import javax.inject.Inject;

import io.reactivex.functions.Consumer;

/**
 * @author 小杜
 *         邮箱:m15701207383@163.com
 * @version V1.0
 * @Description: ${TODO}(用一句话描述该文件做什么)
 * @date 2018/1/11 13:50
 */

public class AppDetailPresenter extends BasePresenter<AppInfoModel, AppDetailContract.View> {

    @Inject
    public AppDetailPresenter(AppDetailContract.View view, AppInfoModel model) {
        super(model, view);
    }

    public void getAppDetail(int id) {
        mModel.getAppDetail(id)
                .compose( RxHttpReponseCompat.<AppInfo>compatResult())
                .subscribe(new Consumer<AppInfo>() {
                    @Override
                    public void accept(AppInfo appInfo) throws Exception {
                        mView.showAppDetail(appInfo);
                    }
                });
    }


}
